package com.wuze.cloud.handler;

import com.wuze.cloud.context.UserContext;
import com.wuze.cloud.pojo.SysUserDO;
import com.wuze.cloud.request.SysFileChunkQuery;
import org.assertj.core.util.Lists;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author wuze
 * @Date 2023/4/28 14:56
 * @ClassName: PDFHandler
 * @Description: TODO
 */
@Component
public class PDFHandler implements FileHandler{

    @Value("${file.accessPath}")
    private String accessPath;

    @Value("${file.uploadFolder}")
    private String uploadFolder;

    @Override
    public List<String> tags() {
        return Lists.newArrayList(".pdf",".txt");
    }

    @Override
    public String handler(SysFileChunkQuery fileDto) throws Exception {

//        //pdf转html
//        PdfConvertHtmlUtil.PDF2HTML(fileDto.getPath(),uploadFolder+"\\html\\"+fileDto.getOpenKey()+".html",fileDto.getName());
//        //pdf生成首页缩略图
//        PdfConvertHtmlUtil.PDF2Image(fileDto.getPath(),uploadFolder+"\\thumbnail\\"+fileDto.getOpenKey()+".png");
//
//        return accessPath+"html/"+fileDto.getOpenKey()+".html";
        SysUserDO user = UserContext.getUser();
        return accessPath+user.getUserName()+"/"+fileDto.getOpenKey()+fileDto.getSuffix();
    }
}
